<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class CompletedExportNotify extends Notification
{
    use Queueable;

    protected $path;

    protected $user;

    protected $title;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($user, $path, $title)
    {
        $this->path = $path;
        $this->user = $user;
        $this->title = $title;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        //mail
        return ['database'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    // public function toMail($notifiable)
    // {
    //     return (new MailMessage)
    //                 ->subject('导出通知')
    //                 ->greeting(config('app.name'))
    //                 ->line($this->title.'-数据导出邮件通知 ！')
    //                 ->action('点击下载', config('app.url').'storage/'.$this->path)
    //                 ->line('感谢使用服务商后台!');
    // }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toDatabase($notifiable)
    {
        return [
            'type' => 'export',
            'path' => 'storage/'.$this->path,
            'title' => $this->title
        ];
    }
}
